<?php

$auth_expireTime = 60;

?>
<!DOCTYPE HTML>
<html>

<head>
	<title>airAuth</title>
	<meta http-equiv="pragma" content="no-cache"/>
	<meta http-equiv="cache-control" content="no-cache"/>
	<meta http-equiv="expires" content="0"/>

	<meta http-equiv="content-type" content="text/html; charset=utf-8"/>

	<meta name="author" content="scumyang@gmail.com"/>
	<meta name="keywords" content="airAuth"/>
	<meta name="description" content="airAuth-login"/>

	<link rel="stylesheet" type="text/css" href="assets/dapi/WebAssets/airAuth_login-l.css?v=2" media="screen and (min-width:300px) "/>
	<link rel="stylesheet" type="text/css" href="assets/dapi/WebAssets/airAuth_login.css?v=2" media="screen and (min-width:800px)"/>
	<link rel="stylesheet" type="text/css" href="assets/dapi/WebAssets/airAuth_login-h.css?v=2" media="screen and (min-width:1400px)"/>

	<!--<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />-->
</head>

<style type="text/css">

</style>

<script type="text/javascript"
src="/wapi/loader/jsLoader?param=
{
	 ignoreError: 0
	,cached: 0
	,syncTimer: 0

	,guid: 'airAuth'
	,mime: 'javascript'
	,pack2: 'swat-pack'

	,path:
	[
		 'file:///services/repo/swatapps/lib/swatJS/'
		,'/'
	]

	,import:
	[
		  'swatJS-v5.js'
		,'spark/SxBase.js'
		,'spark/SxPopTips.js'
	]
}"></script>

<script type="text/javascript">
//$.autoCalcRem( screen.width * 2 );
$G =
{
	 authHost: '/airAuth/'

	,do_signIn: function()
	{
		var e = $('#ed_cpnum'),
			cpnum = e.value(),
			captcha = $('#ed_captcha').value()
			;

		if( ! /\d{11}/.test( cpnum ) )
		{
			tips.show( '请输入正确的手机号码' );
			e.fire('focus');
		}
		else
		{
			$.ajax.load(
			{
				 url: '{0}login?action=signIn&cpnum={1}&captcha={2}&<?=$routeInfo?>'
				 		.format( $G.authHost, cpnum, captcha )
				,type: 'json'
				,onLoad: function(R)
				{
					$.log(R);
					if( R.success == 1 )
					{
						tips.show( R.msg + "\n申请路由验证" );
						location.href = R.redir;
					}
					else
					{
						tips.show( R.msg );
						if( R.code == 'E601' )
						{
							$('#btn_Login').text( '获取验证码' );
							$E('btn_Login').onclick = $G.do_getCaptcha;
						}
					}
				}
			});
		}
	}

	,do_getCaptcha: function()
	{
		var e = $('#ed_cpnum');
		if( ! /\d{11}/.test( e.value() ) )
		{
			tips.show( '请输入正确的手机号码' );
			e.fire('focus');
		}
		else
		{
			$.ajax.load(
			{
				 url: '{0}getCaptcha?type=sms&kind=signIn&cpnum={1}'.format( $G.authHost, e.value() )
				,type: 'json'
				,onLoad: function(R)
				{
					$.log(R);
					if( R.success == 1 )
					{
						tips.show( R.msg );
						$('#btn_Login').text( '登入' );
						$E('btn_Login').onclick = $G.do_signIn;
						$('#eCaptcha').show();
					}
					else
					{
						tips.show( R.msg );
					}
				}
			});
		}
	}
}

$.pageReady( function()
{
	new scumix.swat.spark.popTips
	({
		 instanceName:'tips'
	});

	$E('btn_Login').onclick = $G.do_signIn;

});
</script>

<body>

<!--组件容器-->
<div id="eCompBox">
	<div id="logo"></div>

	<div id="loginForm">
		<div id="accessTips">
		<li>请输入手机号登入</li>
		<li>首次登入需要进行短信授权，已验证过的号码将直接转到互联网</li>
		<li>授权有效时间为 <?=$auth_expireTime?> 分钟</li>
		</div>

		<div class="item">
			手机号: <input id="ed_cpnum" type="tel" value2="18621815200" maxlength="11" placeholder="请输入手机号"/>
		</div>
		<div class="item" id="eCaptcha">
			验证码: <input id="ed_captcha" type="tel" value="" maxlength="4" placeholder=""/>
		</div>
		<button id="btn_Login">登入</button>
		<div id="tips"></div>
	</div>

	<h6 id="footer">Copyright &copy; 2014-2017, ZensVision<sup>&trade;</sup> Co.,Ltd.</h6>

</div>

</body>
</html>